package com.tzinfo.tzt.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONArray;
import org.json.JSONObject;

import android.util.Log;

import com.tzinfo.tzt.domain.FalsityFeedback;
import com.tzinfo.tzt.domain.FjhMovList;
import com.tzinfo.tzt.domain.HouseVillage;
import com.tzinfo.tzt.domain.LocationGeocoder;
import com.tzinfo.tzt.domain.MyResultList;
import com.tzinfo.tzt.domain.NewhouseBuyInfo;
import com.tzinfo.tzt.domain.NewhouseDetail;
import com.tzinfo.tzt.domain.NewhouseDetailHousePic;
import com.tzinfo.tzt.domain.NewhouseDetailInfos;
import com.tzinfo.tzt.domain.NewhouseDetailParas;
import com.tzinfo.tzt.domain.NewhouseDetailPosition;
import com.tzinfo.tzt.domain.NewhouseHouseDetail;
import com.tzinfo.tzt.domain.NewhouseHouseType;
import com.tzinfo.tzt.domain.NewhouseHouseTypeItem;
import com.tzinfo.tzt.domain.NewhouseList;
import com.tzinfo.tzt.domain.NewhouseNewsDetail;
import com.tzinfo.tzt.domain.OldhouseAgent;
import com.tzinfo.tzt.domain.OldhouseDetail;
import com.tzinfo.tzt.domain.OldhouseDetailAgent;
import com.tzinfo.tzt.domain.OldhouseDetailInfos;
import com.tzinfo.tzt.domain.OldhouseDetailVillage;
import com.tzinfo.tzt.domain.OldhouseList;
import com.tzinfo.tzt.domain.OldhousePubDetail;
import com.tzinfo.tzt.domain.OldhousePubDetail.Pics;
import com.tzinfo.tzt.domain.OldhouseVillage;
import com.tzinfo.tzt.domain.OldhouseVillageMap;
import com.tzinfo.tzt.domain.RenthouseDetail;
import com.tzinfo.tzt.domain.RenthouseDetailAgent;
import com.tzinfo.tzt.domain.RenthouseDetailInfos;
import com.tzinfo.tzt.domain.RenthouseDetailVillage;
import com.tzinfo.tzt.domain.RenthouseList;
import com.tzinfo.tzt.domain.RenthousePubDetail;
import com.tzinfo.tzt.domain.RenthouseVillage;

public class JsonTools {

	/**
	 * 获得当前所有楼盘的信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */
	public static MyResultList getNewhouseList(String jsonString) {
		MyResultList newHouseResultList = new MyResultList();
		NewhouseList newhouseList;
		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONArray jsonArray_data = null;
		JSONObject jsonObject_data = null;
		try {
			jsonObject = new JSONObject(jsonString);
			try {
				newHouseResultList.setSuccess(jsonObject.optBoolean("success"));
				newHouseResultList.setErrorMessage(jsonObject.optString("msg"));
				jsonArray_data = jsonObject.optJSONArray("data");
				for (int i = 0; i < jsonArray_data.length(); i++) {
					jsonObject_data = jsonArray_data.optJSONObject(i);
					newhouseList = new NewhouseList();
					int id = jsonObject_data.optInt("Id");
					if (id != 0) {
						newhouseList.setId(id);
					} else {
						newhouseList.setId(jsonObject_data.optInt("ID"));
					}

					newhouseList.setName(jsonObject_data.optString("Name"));
					newhouseList.setAddress(jsonObject_data
							.optString("Address"));
					newhouseList.setLogo(jsonObject_data.optString("Logo"));
					// 解决接口key拼错
					String status = jsonObject_data.optString("Status");
					if (status == null || "".equals(status)) {
						newhouseList.setStatus(jsonObject_data
								.optString("Stauts"));
					} else {
						newhouseList.setStatus(status);
					}
					newhouseList.setAttr(jsonObject_data.optInt("Attr"));
					newhouseList.setPrice(jsonObject_data.optInt("Price"));
					newhouseList.setPriceUnit(jsonObject_data
							.optString("PriceUnit"));
					newhouseList.setLon(jsonObject_data.optDouble("Lon"));
					newhouseList.setLat(jsonObject_data.optDouble("Lat"));
					list.add(newhouseList);
				}
				newHouseResultList.setData(list);
			} catch (Exception e) {
				newHouseResultList.setSuccess(false);
				newHouseResultList.setErrorMessage(jsonObject.optString("msg"));
			}
		} catch (Exception e) {
			newHouseResultList.setSuccess(false);
			newHouseResultList.setErrorMessage("获取信息失败！");
		}

		return newHouseResultList;
	}

	/**
	 * 获得当前id对应楼盘的信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getNewhouseDetail(String jsonString) {
		MyResultList newHouseDetailList = new MyResultList();
		NewhouseDetail newhouseDetail;
		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		JSONArray jsonArray_item = null;
		try {
			jsonObject = new JSONObject(jsonString);
			try {
				newhouseDetail = new NewhouseDetail();
				newHouseDetailList.setSuccess(jsonObject.optBoolean("success"));
				newHouseDetailList.setErrorMessage(jsonObject.optString("msg"));

				Map<String, String> pics = new HashMap<String, String>();
				jsonObject_data = jsonObject.optJSONObject("data");
				// 得到图片信息
				JSONObject jsonObject_pics = jsonObject_data
						.optJSONObject("Pics");
				for (int i = 0, n = 0; i < jsonObject_pics.length(); i++) {
					jsonArray_item = jsonObject_pics.optJSONArray("Pics"
							+ (i + 1));
					for (int j = 0; j < jsonArray_item.length(); j++) {
						pics.put("Pics" + (n + 1), jsonArray_item
								.optJSONObject(j).optString("Url"));
						n++;
					}
				}
				newhouseDetail.setId(jsonObject_data.optInt("ID"));
				newhouseDetail.setUrl(jsonObject_data.optString("Url"));
				newhouseDetail.setPics(pics);

				// 得到楼盘基本信息
				JSONObject jsonObject_infos = jsonObject_data
						.optJSONObject("Infos");
				NewhouseDetailInfos newhouseDetailInfos = new NewhouseDetailInfos();
				newhouseDetailInfos.setName(jsonObject_infos.optString("Name"));
				String status=jsonObject_infos.optString("Status");
				if(status==null||"".equals(status)){
					status=jsonObject_infos.optString("Stauts");
				}
				newhouseDetailInfos.setStatus(status);
				newhouseDetailInfos.setPrice(jsonObject_infos.optInt("Price"));
				newhouseDetailInfos.setPriceUnit(jsonObject_infos
						.optString("PriceUnit"));
				newhouseDetailInfos.setTel(jsonObject_infos.optString("Tel"));
				newhouseDetail.setInfos(newhouseDetailInfos);

				// 添加位置信息
				JSONObject jsonObject_position = jsonObject_data
						.optJSONObject("Position");
				NewhouseDetailPosition newhouseDetailPosition = new NewhouseDetailPosition();
				newhouseDetailPosition.setAddress(jsonObject_position
						.optString("Address"));
				newhouseDetailPosition.setLon(jsonObject_position
						.optDouble("Lon"));
				newhouseDetailPosition.setLat(jsonObject_position
						.optDouble("Lat"));
				newhouseDetailPosition.setTransit(jsonObject_position
						.optString("Transit"));
				newhouseDetailPosition.setSchool(jsonObject_position
						.optString("School"));
				newhouseDetail.setPosition(newhouseDetailPosition);

				// 添加楼盘基本参数
				JSONObject jsonObject_paras = jsonObject_data
						.optJSONObject("Paras");
				NewhouseDetailParas newhouseDetailParas = new NewhouseDetailParas();
				newhouseDetailParas.setBuildType(jsonObject_paras
						.optString("BuildType"));
				newhouseDetailParas.setDecorate(jsonObject_paras
						.optString("Decorate"));
				newhouseDetailParas.setOpenTime(jsonObject_paras
						.optString("OpenTime"));
				newhouseDetail.setParas(newhouseDetailParas);

				// 添加楼盘户型
				JSONArray jsonArray_housePic = jsonObject_data
						.optJSONArray("HousePic");
				List<NewhouseDetailHousePic> newhouseDetailHousePicList = new ArrayList<NewhouseDetailHousePic>();
				for (int i = 0; i < jsonArray_housePic.length(); i++) {
					JSONObject jsonObject_housePic = jsonArray_housePic
							.optJSONObject(i);
					NewhouseDetailHousePic newhouseDetailHousePic = new NewhouseDetailHousePic();
					newhouseDetailHousePic.setId(jsonObject_housePic
							.optInt("ID"));
					newhouseDetailHousePic.setPic(jsonObject_housePic
							.optString("Pic"));
					newhouseDetailHousePic.setNo(jsonObject_housePic
							.optString("No"));
					newhouseDetailHousePic.setName(jsonObject_housePic
							.optString("Name"));
					newhouseDetailHousePic.setSize(jsonObject_housePic
							.optString("Size"));
					newhouseDetailHousePic.setDirection(jsonObject_housePic
							.optString("Direction"));
					newhouseDetailHousePicList.add(newhouseDetailHousePic);
					newhouseDetail.setHousePicList(newhouseDetailHousePicList);
				}

				// 添加楼盘动态
				JSONArray jsonArray_news = jsonObject_data.optJSONArray("News");
				List<NewhouseNewsDetail> newhouseDetailNewsList = new ArrayList<NewhouseNewsDetail>();
				for (int i = 0; i < jsonArray_news.length(); i++) {
					JSONObject jsonObject_news = jsonArray_news
							.optJSONObject(i);
					NewhouseNewsDetail newhouseDetailNews = new NewhouseNewsDetail();
					newhouseDetailNews.setId(jsonObject_news.optInt("ID") + "");
					newhouseDetailNews.setTitle(jsonObject_news
							.optString("Title"));
					newhouseDetailNews.setContent(jsonObject_news
							.optString("Content"));
					newhouseDetailNews.setPubTime(jsonObject_news
							.optString("PubTime"));
					newhouseDetailNewsList.add(newhouseDetailNews);
					newhouseDetail.setNewsList(newhouseDetailNewsList);
				}

				list.add(newhouseDetail);
				newHouseDetailList.setData(list);
			} catch (Exception e) {
				newHouseDetailList.setSuccess(false);
				newHouseDetailList.setErrorMessage(jsonObject.optString("msg"));
			}
		} catch (Exception e) {
			Log.e("Error", e.getMessage());
			newHouseDetailList.setSuccess(false);
			newHouseDetailList.setErrorMessage("获取信息失败！");
		}
		return newHouseDetailList;
	}

	/**
	 * 获得当前id对应新房楼盘参数详情
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getNewhouseHouseDetail(String jsonString) {
		MyResultList newhouseHouseDetailList = new MyResultList();
		NewhouseHouseDetail newhouseHouseDetail;
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		try {
			newhouseHouseDetail = new NewhouseHouseDetail();
			jsonObject = new JSONObject(jsonString);
			newhouseHouseDetailList
					.setSuccess(jsonObject.optBoolean("success"));
			newhouseHouseDetailList
					.setErrorMessage(jsonObject.optString("msg"));
			jsonObject_data = jsonObject.optJSONObject("data");

			newhouseHouseDetail.setOpenTime(jsonObject_data
					.optString("OpenTime"));
			newhouseHouseDetail.setGiveTime(jsonObject_data
					.optString("GiveTime"));
			newhouseHouseDetail.setDeveloper(jsonObject_data
					.optString("Developer"));
			newhouseHouseDetail.setManageCompany(jsonObject_data
					.optString("ManageCompany"));
			newhouseHouseDetail.setBuildType(jsonObject_data
					.optString("BuildType"));
			newhouseHouseDetail.setDecorate(jsonObject_data
					.optString("Decorate"));
			newhouseHouseDetail.setArea(jsonObject_data.optString("Area"));
			newhouseHouseDetail.setBuildArea(jsonObject_data
					.optString("BuildArea"));
			newhouseHouseDetail.setFamilyCount(jsonObject_data
					.optString("FamilyCount"));
			newhouseHouseDetail.setCarPlace(jsonObject_data
					.optString("CarPlace"));
			newhouseHouseDetail.setPlotRatio(jsonObject_data
					.optString("PlotRatio"));
			newhouseHouseDetail.setGreeningRate(jsonObject_data
					.optString("GreeningRate"));

			List<Object> list = new ArrayList<Object>();
			list.add(newhouseHouseDetail);
			newhouseHouseDetailList.setData(list);

		} catch (Exception e) {
			Log.e("error", e.getMessage());
			newhouseHouseDetailList.setSuccess(false);
			newhouseHouseDetailList.setErrorMessage("获取信息失败！");
		}
		return newhouseHouseDetailList;
	}

	/**
	 * 新房楼盘动态列表，可列出所有动态或某个楼盘相关动态
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */
	public static MyResultList getNewhouseNewsList(String jsonString) {
		MyResultList result = new MyResultList();
		NewhouseNewsDetail newhouseNewsDetail;
		JSONObject jsonObject = null;
		JSONArray jsonArray_data = null;
		JSONObject jsonObject_data = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonArray_data = jsonObject.optJSONArray("data");

			List<Object> list = new ArrayList<Object>();
			for (int i = 0; i < jsonArray_data.length(); i++) {
				newhouseNewsDetail = new NewhouseNewsDetail();
				jsonObject_data = jsonArray_data.optJSONObject(i);
				newhouseNewsDetail.setId(jsonObject_data.optInt("ID") + "");
				newhouseNewsDetail.setTitle(jsonObject_data.optString("Title"));
				newhouseNewsDetail.setContent(jsonObject_data
						.optString("Content"));
				newhouseNewsDetail.setPubTime(jsonObject_data
						.optString("PubTime"));

				list.add(newhouseNewsDetail);
			}
			result.setData(list);

		} catch (Exception e) {
			Log.e("error", e.getMessage());
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}

	/**
	 * 获得当前id对应新房楼盘参数详情
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getNewhouseNewsDetail(String jsonString) {
		MyResultList result = new MyResultList();
		NewhouseNewsDetail newhouseNewsDetail;
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		try {
			newhouseNewsDetail = new NewhouseNewsDetail();
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonObject_data = jsonObject.optJSONObject("data");

			List<Object> list = new ArrayList<Object>();
			newhouseNewsDetail.setId(jsonObject_data.optInt("ID") + "");
			newhouseNewsDetail.setTitle(jsonObject_data.optString("Title"));
			newhouseNewsDetail.setContent(jsonObject_data.optString("Content"));
			newhouseNewsDetail.setPubTime(jsonObject_data.optString("PubTime"));

			list.add(newhouseNewsDetail);
			result.setData(list);

		} catch (Exception e) {
			Log.e("error", e.getMessage());
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}
		return result;
	}

	/**
	 * 获得当前id对应新房楼盘参数详情
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getNewhouseHouseType(String jsonString) {
		MyResultList result = new MyResultList();
		NewhouseHouseType newhouseHouseType;
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;

		try {
			newhouseHouseType = new NewhouseHouseType();

			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonObject_data = jsonObject.optJSONObject("data");

			JSONArray jsonArray_type = jsonObject_data.optJSONArray("Type");
			List<String> nameList = new ArrayList<String>();
			for (int i = 0; i < jsonArray_type.length(); i++) {
				JSONObject jsonObject_name = jsonArray_type.optJSONObject(i);
				nameList.add(jsonObject_name.optString("Name").trim());
			}
			newhouseHouseType.setTypeNameList(nameList);

			JSONArray jsonArray_List = jsonObject_data.optJSONArray("List");
			List<NewhouseHouseTypeItem> listList = new ArrayList<NewhouseHouseTypeItem>();
			for (int i = 0; i < jsonArray_type.length(); i++) {
				NewhouseHouseTypeItem item = new NewhouseHouseTypeItem();
				JSONObject jsonObject_item = jsonArray_List.optJSONObject(i);
				item.setTypeName(jsonObject_item.optString("TypeName").trim());
				item.setID(jsonObject_item.optInt("ID") + "");
				item.setPic(jsonObject_item.optString("Pic"));
				item.setNo(jsonObject_item.optString("No"));
				item.setName(jsonObject_item.optString("Name").trim());
				item.setSize(jsonObject_item.optString("Size"));
				item.setDirection(jsonObject_item.optString("Direction"));
				item.setContent(jsonObject_item.optString("Content"));
				listList.add(item);
			}
			newhouseHouseType.setList(listList);

			List<Object> list = new ArrayList<Object>();
			list.add(newhouseHouseType);
			result.setData(list);

		} catch (Exception e) {
			Log.e("error", e.getMessage());
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}

	// =============二手房=================================================
	/**
	 * 获得当前所有二手房的信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */
	public static MyResultList getOldhouseList(String jsonString) {
		MyResultList result = new MyResultList();
		OldhouseList oldhouseList;
		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONArray jsonArray_data = null;
		JSONObject jsonObject_data = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonArray_data = jsonObject.optJSONArray("data");
			for (int i = 0; i < jsonArray_data.length(); i++) {
				jsonObject_data = jsonArray_data.optJSONObject(i);
				oldhouseList = new OldhouseList();
				oldhouseList.setID(jsonObject_data.optInt("Id"));
				oldhouseList.setName(jsonObject_data.optString("Name"));
				oldhouseList.setAddress(jsonObject_data.optString("Address"));
				oldhouseList.setLogo(jsonObject_data.optString("Logo"));
				oldhouseList.setStyle(jsonObject_data.optString("Style"));
				oldhouseList.setSize(jsonObject_data.optString("Size"));
				// 取整
				double price = Double.parseDouble(jsonObject_data
						.optString("Price"));
				oldhouseList.setPrice((int) price + "万");
				oldhouseList.setLon(jsonObject_data.optDouble("Lon"));
				oldhouseList.setLat(jsonObject_data.optDouble("Lat"));
				list.add(oldhouseList);
			}
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}

	
	
	/**
	 * 获得当前所有二手房小区信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */
	public static MyResultList getOldhouseVillageMap(String jsonString) {
		MyResultList result = new MyResultList();
		OldhouseVillageMap oldhouseVillageMap;
		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONArray jsonArray_data = null;
		JSONObject jsonObject_data = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonArray_data = jsonObject.optJSONArray("data");
			for (int i = 0; i < jsonArray_data.length(); i++) {
				jsonObject_data = jsonArray_data.optJSONObject(i);
				oldhouseVillageMap = new OldhouseVillageMap();
				oldhouseVillageMap.setID(jsonObject_data.optInt("Id"));
				oldhouseVillageMap.setName(jsonObject_data.optString("Name"));
				oldhouseVillageMap.setHouseCount(jsonObject_data.optString("HouseCount"));
				oldhouseVillageMap.setLon(jsonObject_data.optDouble("Lon"));
				oldhouseVillageMap.setLat(jsonObject_data.optDouble("Lat"));
				list.add(oldhouseVillageMap);
			}
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}
	/**
	 * 获得当前id对应楼盘的信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getOldhouseDetail(String jsonString) {
		MyResultList result = new MyResultList();
		OldhouseDetail oldhouseDetail;

		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		try {
			// 得到所有base数据
			jsonObject = new JSONObject(jsonString);
			oldhouseDetail = new OldhouseDetail();
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonObject_data = jsonObject.optJSONObject("data");

			oldhouseDetail.setID(jsonObject_data.optInt("ID"));
			//分享的Url
			oldhouseDetail.setUrl(jsonObject_data.optString("Url"));
			// 得到图片信息
			List<String> picList = new ArrayList<String>();
			JSONArray jsonArray_pics = jsonObject_data.optJSONArray("Pics");
			for (int i = 0; i < jsonArray_pics.length(); i++) {
				picList.add(jsonArray_pics.optJSONObject(i).optString("Url"));
			}
			oldhouseDetail.setPics(picList);

			// 得到房子基本信息
			JSONObject jsonObject_infos = jsonObject_data
					.optJSONObject("Infos");
			OldhouseDetailInfos infos = new OldhouseDetailInfos();

			infos.setName(jsonObject_infos.optString("Name"));
			infos.setDescribe(jsonObject_infos.optString("Describe"));
			infos.setPrice(jsonObject_infos.optString("Price"));
			infos.setPriceUnit(jsonObject_infos.optString("PriceUnit"));
			infos.setStyle(jsonObject_infos.optString("Style"));
			infos.setStylePic(jsonObject_infos.optString("StylePic"));
			infos.setSize(jsonObject_infos.optString("Size"));
			infos.setDirection(jsonObject_infos.optString("Direction"));
			infos.setFloor(jsonObject_infos.optString("Floor"));
			infos.setDecorate(jsonObject_infos.optString("Decorate"));
			infos.setBuildYear(jsonObject_infos.optString("BuildYear"));
			oldhouseDetail.setInfos(infos);

			// 得到小区信息
			JSONObject jsonObject_Village = jsonObject_data
					.optJSONObject("Village");
			OldhouseDetailVillage village = new OldhouseDetailVillage();

			village.setID(jsonObject_Village.optInt("ID"));
			village.setName(jsonObject_Village.optString("Name"));
			village.setAddress(jsonObject_Village.optString("Address"));
			village.setLon(jsonObject_Village.optDouble("Lon"));
			village.setLat(jsonObject_Village.optDouble("Lat"));
			village.setTransit(jsonObject_Village.optString("Transit"));
			village.setSchool(jsonObject_Village.optString("School"));
			village.setHouseCount(jsonObject_Village.optString("HouseCount"));
			oldhouseDetail.setVillage(village);

			// 得到经纪人
			JSONObject jsonObject_Agent = jsonObject_data
					.optJSONObject("Agent");
			OldhouseDetailAgent agent = new OldhouseDetailAgent();

			agent.setID(jsonObject_Agent.optInt("ID"));
			agent.setName(jsonObject_Agent.optString("Name"));
			agent.setTel(jsonObject_Agent.optString("Tel"));
			oldhouseDetail.setAgent(agent);

			// 装入list
			list.add(oldhouseDetail);
			// 装入结果类
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}
		return result;
	}

	
	/**
	 * 获得当前id对应小区的信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getOldhouseVillage(String jsonString) {
		MyResultList result = new MyResultList();
		OldhouseVillage detail;

		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		try {
			// 得到所有base数据
			jsonObject = new JSONObject(jsonString);
			detail = new OldhouseVillage();
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			if(!result.getSuccess())return result;
			jsonObject_data = jsonObject.optJSONObject("data");

			
			detail.setID(jsonObject_data.optInt("ID"));
			// 得到图片信息
			List<String> picList = new ArrayList<String>();
			JSONArray jsonArray_pics = jsonObject_data.optJSONArray("Pics");
			for (int i = 0; i < jsonArray_pics.length(); i++) {
				picList.add(jsonArray_pics.optJSONObject(i).getString("Url"));
			}
			detail.setPics(picList);
			
			detail.setName(jsonObject_data.optString("Name"));
			detail.setAddress(jsonObject_data.optString("Address"));
			detail.setLon(jsonObject_data.optDouble("Lon"));
			detail.setLat(jsonObject_data.optDouble("Lat"));
			detail.setBuildType(jsonObject_data.optString("BuildType"));
			detail.setBuildYear(jsonObject_data.optString("BuildYear"));
			detail.setDeveloper(jsonObject_data.optString("Developer"));
			detail.setManageCompany(jsonObject_data.optString("ManageCompany"));
			detail.setTransit(jsonObject_data.optString("Transit"));
			detail.setSchool(jsonObject_data.optString("School"));
			detail.setDescribe(jsonObject_data.optString("Describe"));
			detail.setLifeSupport(jsonObject_data.optString("LifeSupport"));
			detail.setAveragePrice(jsonObject_data.optString("AveragePrice"));
			detail.setPriceIncrease(jsonObject_data.optDouble("PriceIncrease"));
			detail.setPriceInfo(jsonObject_data.optString("PriceInfo"));
			detail.setPricePic(jsonObject_data.optString("PricePic"));
			detail.setHouseCount(jsonObject_data.optString("HouseCount"));
			
			// 装入list
			list.add(detail);
			// 装入结果类
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}
		return result;
	}
	
	
	
	/**
	 * 获得当前id对应小区的信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含若干个data信息对象的自定义MyResultList
	 */

	public static MyResultList getOldhouseAgent(String jsonString) {
		MyResultList result = new MyResultList();
		OldhouseAgent detail;

		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		try {
			// 得到所有base数据
			jsonObject = new JSONObject(jsonString);
			detail = new OldhouseAgent();
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonObject_data = jsonObject.optJSONObject("data");

			
			detail.setID(jsonObject_data.optInt("ID"));
			
			detail.setName(jsonObject_data.optString("Name"));
			detail.setPhoto(jsonObject_data.optString("Photo"));
			detail.setTel(jsonObject_data.optString("Tel"));
			detail.setServiceArea(jsonObject_data.optString("ServiceArea"));
			detail.setStarLevel(jsonObject_data.optInt("StarLevel"));
			detail.setRanking(jsonObject_data.optString("Ranking"));
			detail.setFeedback(jsonObject_data.optString("Feedback"));
			detail.setHouseCount(jsonObject_data.optString("HouseCount"));
			// 装入list
			list.add(detail);
			// 装入结果类
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}
		return result;
	}
	
	// =============租房=================================================
		/**
		 * 获得当前所有租房的信息
		 * 
		 * @param 获取到的String类型的JSON数据
		 * @return 返回一个包含若干个data信息对象的自定义MyResultList
		 */
		public static MyResultList getRenthouseList(String jsonString) {
			MyResultList result = new MyResultList();
			RenthouseList renthouseList;
			List<Object> list = new ArrayList<Object>();
			JSONObject jsonObject = null;
			JSONArray jsonArray_data = null;
			JSONObject jsonObject_data = null;
			try {
				jsonObject = new JSONObject(jsonString);
				result.setSuccess(jsonObject.optBoolean("success"));
				result.setErrorMessage(jsonObject.optString("msg"));
				jsonArray_data = jsonObject.optJSONArray("data");
				for (int i = 0; i < jsonArray_data.length(); i++) {
					jsonObject_data = jsonArray_data.optJSONObject(i);
					renthouseList = new RenthouseList();
					renthouseList.setID(jsonObject_data.optInt("Id"));
					renthouseList.setName(jsonObject_data.optString("Name"));
					renthouseList.setAddress(jsonObject_data.optString("Address"));
					renthouseList.setLogo(jsonObject_data.optString("Logo"));
					renthouseList.setStyle(jsonObject_data.optString("Style"));
					
					// 取整
					double price = Double.parseDouble(jsonObject_data
							.optString("Price"));
					renthouseList.setPrice((int) price + "元");
					renthouseList.setPriceUnit(jsonObject_data.optString("PriceUnit"));
					renthouseList.setLon(jsonObject_data.optDouble("Lon"));
					renthouseList.setLat(jsonObject_data.optDouble("Lat"));
					list.add(renthouseList);
				}
				result.setData(list);
			} catch (Exception e) {
				result.setSuccess(false);
				result.setErrorMessage("获取信息失败！");
			}

			return result;
		}
		
		
		
		
		/**
		 * 获得当前id对应楼盘的信息
		 * 
		 * @param 获取到的String类型的JSON数据
		 * @return 返回一个包含若干个data信息对象的自定义MyResultList
		 */

		public static MyResultList getRenthouseDetail(String jsonString) {
			MyResultList result = new MyResultList();
			RenthouseDetail renthouseDetail;

			List<Object> list = new ArrayList<Object>();
			JSONObject jsonObject = null;
			JSONObject jsonObject_data = null;
			try {
				// 得到所有base数据
				jsonObject = new JSONObject(jsonString);
				renthouseDetail = new RenthouseDetail();
				result.setSuccess(jsonObject.optBoolean("success"));
				result.setErrorMessage(jsonObject.optString("msg"));
				jsonObject_data = jsonObject.optJSONObject("data");

				// 得到图片信息
				renthouseDetail.setID(jsonObject_data.optInt("ID"));
				renthouseDetail.setUrl(jsonObject_data.optString("Url"));
				List<String> picList = new ArrayList<String>();
				JSONArray jsonArray_pics = jsonObject_data.optJSONArray("Pics");
				for (int i = 0; i < jsonArray_pics.length(); i++) {
					picList.add(jsonArray_pics.optJSONObject(i).optString("Url"));
				}
				renthouseDetail.setPics(picList);

				// 得到房子基本信息
				JSONObject jsonObject_infos = jsonObject_data
						.optJSONObject("Infos");
				RenthouseDetailInfos infos = new RenthouseDetailInfos();

				infos.setName(jsonObject_infos.optString("Name"));
				infos.setPrice(jsonObject_infos.optString("Price"));
				infos.setPriceUnit(jsonObject_infos.optString("PriceUnit"));
				infos.setStyle(jsonObject_infos.optString("Style"));
				infos.setSize(jsonObject_infos.optString("Size"));
				infos.setDirection(jsonObject_infos.optString("Direction"));
				infos.setFloor(jsonObject_infos.optString("Floor"));
				infos.setDecorate(jsonObject_infos.optString("Decorate"));
				infos.setBuildType(jsonObject_infos.optString("BuildType"));
				infos.setDevice(jsonObject_infos.optString("Device"));
				infos.setDescribe(jsonObject_infos.optString("Describe"));
				infos.setFalsity(jsonObject_infos.optInt("Falsity"));
				renthouseDetail.setInfos(infos);

				// 得到小区信息
				JSONObject jsonObject_Village = jsonObject_data
						.optJSONObject("Village");
				RenthouseDetailVillage village = new RenthouseDetailVillage();

				village.setID(jsonObject_Village.optInt("ID"));
				village.setName(jsonObject_Village.optString("Name"));
				village.setAddress(jsonObject_Village.optString("Address"));
				village.setLon(jsonObject_Village.optDouble("Lon"));
				village.setLat(jsonObject_Village.optDouble("Lat"));
				renthouseDetail.setVillage(village);

				// 得到小区信息
				JSONObject jsonObject_Agent = jsonObject_data
						.optJSONObject("Agent");
				RenthouseDetailAgent agent = new RenthouseDetailAgent();

				agent.setID(jsonObject_Agent.optInt("ID"));
				agent.setName(jsonObject_Agent.optString("Name"));
				agent.setTel(jsonObject_Agent.optString("Tel"));
				agent.setFace(jsonObject_Agent.optString("Face"));
				agent.setCompany(jsonObject_Agent.optString("Company"));
				renthouseDetail.setAgent(agent);

				// 装入list
				list.add(renthouseDetail);
				// 装入结果类
				result.setData(list);
			} catch (Exception e) {
				Log.e("Error", e.getMessage());
				result.setSuccess(false);
				result.setErrorMessage("获取信息失败！");
			}
			return result;
		}
		
		/**
		 * 获得当前id对应小区的信息
		 * 
		 * @param 获取到的String类型的JSON数据
		 * @return 返回一个包含若干个data信息对象的自定义MyResultList
		 */

		public static MyResultList getRenthouseVillage(String jsonString) {
			MyResultList result = new MyResultList();
			RenthouseVillage detail;

			List<Object> list = new ArrayList<Object>();
			JSONObject jsonObject = null;
			JSONObject jsonObject_data = null;
			try {
				// 得到所有base数据
				jsonObject = new JSONObject(jsonString);
				detail = new RenthouseVillage();
				result.setSuccess(jsonObject.optBoolean("success"));
				result.setErrorMessage(jsonObject.optString("msg"));
				jsonObject_data = jsonObject.optJSONObject("data");

				
				detail.setID(jsonObject_data.optInt("ID"));
				// 得到图片信息
				List<String> picList = new ArrayList<String>();
				JSONArray jsonArray_pics = jsonObject_data.optJSONArray("Pics");
				for (int i = 0; i < jsonArray_pics.length(); i++) {
					picList.add(jsonArray_pics.optJSONObject(i).getString("Url"));
				}
				detail.setPics(picList);
				
				detail.setName(jsonObject_data.optString("Name"));
				detail.setAddress(jsonObject_data.optString("Address"));
				detail.setLon(jsonObject_data.optDouble("Lon"));
				detail.setLat(jsonObject_data.optDouble("Lat"));
				detail.setBuildYear(jsonObject_data.optString("BuildYear"));
				detail.setBuildType(jsonObject_data.optString("BuildType"));
				detail.setCarPlace(jsonObject_data.optString("CarPlace"));
				detail.setDescribe(jsonObject_data.optString("Describe"));
				detail.setLifeSupport(jsonObject_data.optString("LifeSupport"));
				detail.setInfo(jsonObject_data.optString("Info"));
				detail.setHouseCount(jsonObject_data.optString("HouseCount"));
				// 装入list
				list.add(detail);
				// 装入结果类
				result.setData(list);
			} catch (Exception e) {
				result.setSuccess(false);
				result.setErrorMessage("获取信息失败！");
			}
			return result;
		}
		
		
	/**
	 * 获得团购详细信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的NewhouseBuyInfo
	 */
	public static MyResultList getNewhouseBuyInfo(String jsonString) {
		MyResultList result = new MyResultList();
		NewhouseBuyInfo info;
		List<Object> list = new ArrayList<Object>();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonObject_data = jsonObject.optJSONObject("data");
			info = new NewhouseBuyInfo();
			if(jsonObject_data!=null){
				// 图片list
				List<String> picsList = new ArrayList<String>();
				JSONArray jsonArray_pics = jsonObject_data.optJSONArray("Pics");
				for (int i = 0; i < jsonArray_pics.length(); i++) {
					picsList.add(jsonArray_pics.optJSONObject(i).optString("Url"));
				}
				info.setPics(picsList);

				JSONObject jsonObject_Inofs = jsonObject_data
						.optJSONObject("Infos");
				info.setName(jsonObject_Inofs.getString("Name"));
				info.setSales(jsonObject_Inofs.getString("Sales"));
				info.setCaption(jsonObject_Inofs.getString("Caption"));
				info.setIsGroup(jsonObject_Inofs.getBoolean("IsGroup"));
				info.setSignCount(jsonObject_Inofs.getString("SignCount"));
				info.setRemainTime(jsonObject_Inofs.getString("RemainTime"));
				info.setIntroduce(jsonObject_Inofs.getString("Introduce"));
				info.setNotice(jsonObject_Inofs.getString("Notice"));

				list.add(info);
			}else{
				result.setSuccess(false);
				result.setErrorMessage("没有数据");
			}
			result.setData(list);
		} catch (Exception e) {
			Log.e("json解析", "解析出错");
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}

	/**
	 * 获得房交会访谈列表信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的MyResultList
	 */
	public static MyResultList getFjhMovList(String jsonString) {
		MyResultList result = new MyResultList();
		List<Object> list;
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		JSONArray jsonArray_data = null;
		FjhMovList data = null;
		try {
			jsonObject = new JSONObject(jsonString);
			list = new ArrayList<Object>();
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonArray_data = jsonObject.optJSONArray("data");

			for (int i = 0; i < jsonArray_data.length(); i++) {
				data = new FjhMovList();
				jsonObject_data = jsonArray_data.optJSONObject(i);
				data.setID(jsonObject_data.optInt("ID"));
				data.setTitle(jsonObject_data.optString("Title"));
				data.setLogo(jsonObject_data.optString("Logo"));
				data.setMovies(jsonObject_data.optJSONArray("Movies").optJSONObject(0).optString("Url"));
				
				list.add(data);
			}
			
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}

	/**
	 * 获得团购详细信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的NewhouseBuyInfo
	 */
	public static MyResultList getNewhouseBuySignResult(String jsonString) {
		MyResultList result = new MyResultList();
		JSONObject jsonObject = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			result.setData(null);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}


	
	
	/**
	 * 获得结果信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的UserInfo
	 */

	public static MyResultList getResult(String jsonString) {
		MyResultList result = new MyResultList();
		JSONObject jsonObject = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			List<Object> list= new ArrayList<Object>();
			list.add(jsonObject.optString("data"));
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}

		return result;
	}
	
	
	/**
	 * 获得结果信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的FalsityFeedback
	 */

	public static FalsityFeedback getFalsityFeedbackResult(String jsonString) {
		FalsityFeedback result = new FalsityFeedback();
		JSONObject jsonObject = null;
		JSONObject jsonObject_msg = null;
		try {
			jsonObject = new JSONObject(jsonString);
			jsonObject_msg=jsonObject.optJSONObject("msg");
			result.setState(jsonObject_msg.optInt("State"));
			result.setMsg(jsonObject_msg.optString("Msg"));
			result.setOperateTime(jsonObject_msg.optString("OperateTime"));
		} catch (Exception e) {
			result.setState(-1);;
			result.setMsg("获取信息失败！");
		}

		return result;
	}
	
	/**
	 * 获得结果信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的OldhousePubDetail
	 */

	public static OldhousePubDetail getOldhousePubDetail(String jsonString) {
		OldhousePubDetail result = new OldhousePubDetail();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		JSONArray jsonObject_array = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setMsg(jsonObject.optString("Msg"));
			jsonObject_data=jsonObject.optJSONObject("data");
			jsonObject_array=jsonObject_data.optJSONArray("Pics");
			result.setID(jsonObject_data.optInt("ID"));
			//设置图片
			List<Pics> list=new ArrayList<Pics>();
			for (int i = 0; i < jsonObject_array.length(); i++) {
				Pics pics=new Pics();
				JSONObject jsonPics=jsonObject_array.optJSONObject(i);
				pics.setPicID(jsonPics.optInt("Picid"));
				pics.setUrl(jsonPics.optString("Url"));
				list.add(pics);
			}
			result.setPics(list);
			JSONObject jsonObject_info=jsonObject_data.optJSONObject("Infos");
			result.setTitle(jsonObject_info.optString("Title"));
			result.setArea(jsonObject_info.optInt("Area"));
			result.setAllFloor(jsonObject_info.optInt("AllFloor"));
			result.setCurrentFloor(jsonObject_info.optInt("CurrentFloor"));
			result.setType(jsonObject_info.optString("Type"));
			result.setAreaqy(jsonObject_info.optString("Areaqy"));
			result.setOrientations(jsonObject_info.optString("Orientations"));
			result.setTotalP(jsonObject_info.optInt("TotalP"));
			result.setDescription(jsonObject_info.optString("Description"));
			result.setAddress(jsonObject_info.optString("Address"));
			result.setCommunityID(jsonObject_info.optInt("CommunityID"));
			result.setCommunityName(jsonObject_info.optString("CommunityName"));
			result.setPubPhone(jsonObject_info.optString("PubPhone"));
			result.setPubName(jsonObject_info.optString("PubName"));
		} catch (Exception e) {
			result.setSuccess(false);
			result.setMsg("获取信息失败！");
		}

		return result;
	}
	
	/**
	 * 获得结果信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的OldhousePubDetail
	 */

	public static RenthousePubDetail getRenthousePubDetail(String jsonString) {
		RenthousePubDetail result = new RenthousePubDetail();
		JSONObject jsonObject = null;
		JSONObject jsonObject_data = null;
		JSONArray jsonObject_array = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setMsg(jsonObject.optString("Msg"));
			jsonObject_data=jsonObject.optJSONObject("data");
			jsonObject_array=jsonObject_data.optJSONArray("Pics");
			result.setID(jsonObject_data.optInt("ID"));
			//设置图片
			List<Pics> list=new ArrayList<Pics>();
			for (int i = 0; i < jsonObject_array.length(); i++) {
				Pics pics=new Pics();
				JSONObject jsonPics=jsonObject_array.optJSONObject(i);
				pics.setPicID(jsonPics.optInt("Picid"));
				pics.setUrl(jsonPics.optString("Url"));
				list.add(pics);
			}
			result.setPics(list);
			JSONObject jsonObject_info=jsonObject_data.optJSONObject("Infos");
			result.setTitle(jsonObject_info.optString("Title"));
			result.setArea(jsonObject_info.optInt("Area"));
			result.setAllFloor(jsonObject_info.optInt("AllFloor"));
			result.setCurrentFloor(jsonObject_info.optInt("CurrentFloor"));
			result.setType(jsonObject_info.optString("Type"));
			result.setAreaqy(jsonObject_info.optString("Areaqy"));
			result.setOrientations(jsonObject_info.optString("Orientations"));
			result.setReprises(jsonObject_info.optInt("Reprises"));
			result.setDescription(jsonObject_info.optString("Description"));
			result.setAddress(jsonObject_info.optString("Address"));
			result.setCommunityID(jsonObject_info.optInt("CommunityID"));
			result.setCommunityName(jsonObject_info.optString("CommunityName"));
			result.setPubPhone(jsonObject_info.optString("PubPhone"));
			result.setPubName(jsonObject_info.optString("PubName"));
		} catch (Exception e) {
			result.setSuccess(false);
			result.setMsg("获取信息失败！");
		}

		return result;
	}

	/**
	 * 获得搜素的小区信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的HouseVillage
	 */
	public static MyResultList getHouseVillageResult(String jsonString) {
		MyResultList result = new MyResultList();
		JSONObject jsonObject = null;
		JSONArray jsonArray_data = null;
		JSONObject jsonObject_item = null;
		try {
			jsonObject = new JSONObject(jsonString);
			result.setSuccess(jsonObject.optBoolean("success"));
			result.setErrorMessage(jsonObject.optString("msg"));
			jsonArray_data=jsonObject.optJSONArray("data");
			List<Object> list=new ArrayList<Object>();
			for (int i = 0; i < jsonArray_data.length(); i++) {
				HouseVillage item=new HouseVillage();
				jsonObject_item=jsonArray_data.optJSONObject(i);
				item.setID(jsonObject_item.optInt("Id"));
				item.setName(jsonObject_item.optString("Name"));
				list.add(item);
			}
			result.setData(list);
		} catch (Exception e) {
			result.setSuccess(false);
			result.setErrorMessage("获取信息失败！");
		}
		return result;
	}

	// =============================百度地图================================

	/**
	 * 获得登录或注册信息
	 * 
	 * @param 获取到的String类型的JSON数据
	 * @return 返回一个包含一个data信息对象的UserInfo
	 */

	public static LocationGeocoder getLocationToAddress(String jsonString) {
		LocationGeocoder geocoder = new LocationGeocoder();
		JSONObject jsonObject = null;
		JSONObject jsonObject_result = null;
		try {
			String[] strs = jsonString.split("[()]");
			jsonString = strs[1];
			jsonObject = new JSONObject(jsonString);
			geocoder.setStatus(jsonObject.optInt("status"));
			geocoder.setErrorMessage(jsonObject.optString("msg"));

			jsonObject_result = jsonObject.optJSONObject("result");
			JSONObject jsonObject_location = jsonObject_result
					.optJSONObject("location");
			geocoder.setLat(jsonObject_location.optDouble("lat"));
			geocoder.setLng(jsonObject_location.optDouble("lng"));

			geocoder.setFormatted_address(jsonObject_result
					.optString("location"));
			geocoder.setBusiness(jsonObject_result.optString("business"));

			JSONObject jsonObject_addressComponent = jsonObject_result
					.optJSONObject("addressComponent");
			geocoder.setStreetNumber(jsonObject_addressComponent
					.optInt("streetNumber"));
			geocoder.setStreet(jsonObject_addressComponent.optString("street"));
			geocoder.setDistrict(jsonObject_addressComponent
					.optString("district"));
			geocoder.setCity(jsonObject_addressComponent.optString("city"));
			geocoder.setProvince(jsonObject_addressComponent
					.optString("province"));

			geocoder.setCityCode(jsonObject_result.optInt("cityCode"));

		} catch (Exception e) {
			e.printStackTrace();
			geocoder.setStatus(5);
			geocoder.setErrorMessage("获取信息失败！");
		}
		return geocoder;
	}
}